package com.lht.leetcodeDemo;

import org.junit.Test;

/**
 * @author Eric
 * @version 1.0
 * @date 2019-05-27
 */
public class LengthOfLastWorld {

    @Test
    public void test(){
        System.out.println(new LengthOfLastWorld().lengthOfLastWord("a"));
    }


    public int lengthOfLastWord(String s) {
        for(int i=s.length()-1;i>=0;i--){
            if(' '==s.charAt(i)){
                return s.length()-1-i;
            }
        }
        return s.length();
    }
}
